package com.sixkey.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sixkey.annotation.OperationLog;
import com.sixkey.entity.Log;
import com.sixkey.entity.User;
import com.sixkey.entity.vo.UserVo;
import com.sixkey.response.Response;
import com.sixkey.service.LogService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName: LogController
 * Package: com.sixkey.controller
 * Description:
 *
 * @Author: @weixueshi
 * @Create: 2023/9/30 - 16:53
 * @Version: v1.0
 */
@Slf4j
@Validated
@CrossOrigin
@RestController
@RequestMapping("/log")
@RequiredArgsConstructor
public class LogController {

    private final LogService logService;

    /**
     * 分页获取日志数据
     * @return
     */
    @GetMapping("/list/{pageNo}/{pageSize}")
    public Response list(@PathVariable("pageNo") Integer pageNo,
                         @PathVariable("pageSize") Integer pageSize) {
        log.info("分页获取日志数据请求进来");
        Page<Log> userPage = logService.queryList(pageNo,pageSize);
        return Response.success(userPage);
    }

    /**
     * 删除日志
     * @param
     * @return
     */
    @DeleteMapping("/remove/{id}")
    @OperationLog("删除日志")
    public Response remove(@PathVariable("id") List<Integer> id){
        log.info("删除日志请求进来");
        logService.removeBatchByIds(id);
        return Response.success();
    }
}
